<?php
/**
 * @Notes:【】
 * @User: zwc
 * @Date: 2022-05-06 16:01
 */

namespace App\Service\WebSocket\Message;


use App\Constants\ChatEvent;
use App\Service\WebSocket\SocketClientService;
use Hyperf\Di\Annotation\Inject;
use Swoole\WebSocket\Frame;

class ReceiveHandleService
{

    /**
     * @Inject()
     * @var SocketClientService
     */
    private $client;

    // 消息事件绑定
    const EVENTS = [
        ChatEvent::EVENT_TALK => 'onTalk',
    ];

    public function onTalk($server, Frame $frame, $data)
    {
        di()->get(TalkMessageService::class)->insertText([
            'talk_type' => $data['talk_type'],
            'user_id' => $data['sender_id'],
            'receiver_id' => $data['receiver_id'],
            'content' => $data['text_message'],
        ]);
    }


}